
<?php
include_once('common/header.php');
if($AppUI->id <= 0 || (isset($_SESSION['blog']) && ($_SESSION['blog'] <= 0))) {
	Vfriend_Function::redirect(HOST_BACKEND);
}
$arrParams = $objRequest->getParams();
$intAction = isset($arrParams['paction']) ? $arrParams['paction'] : 0;
$arrUserId = isset($arrParams['puserid']) ? $arrParams['puserid'] : null;
$strBackUrl= isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : HOST_BACKEND;
$intError  = 0;
if($intAction) {
	switch ($intAction) {
		case 1: // active
			if(isset($_SESSION['user']) && ($_SESSION['user']&1<<5) != 0) {
				if($arrUserId) {
					$objVfriendUser = new Vfriend_User();
					$strLogs		= Vfriend_Function::setUserLogs($AppUI->id, 1);					
					foreach($arrUserId as $row) {
						$objVfriendUser->updateStatuses($row,1,$strLogs);
					}
				} else {
					$intError = 1;
				}
			}
			else {
				$intError = 1;
			}
			break;
		case 2: // delete
			if(isset($_SESSION['user']) && ($_SESSION['user']&1<<3) != 0) {
				if($arrUserId) {
					$objVfriendUser = new Vfriend_User();
					$strLogs		= Vfriend_Function::setUserLogs($AppUI->id, 4);
					foreach($arrUserId as $row) {
						$objVfriendUser->updateStatuses($row,4,$strLogs);
					}
				} else {
					$intError = 1;
				}
			}
			else {
				$intError = 1;
			}
			break;
		case 3: // suspend
			if(isset($_SESSION['user']) && ($_SESSION['user']&1<<4) != 0) {
				if($arrUserId) {
					$objVfriendUser = new Vfriend_User();
					$strLogs		= Vfriend_Function::setUserLogs($AppUI->id, 3);
					foreach($arrUserId as $row) {
						$objVfriendUser->updateStatuses($row,3,$strLogs);
					}
				} else {
					$intError = 1;
				}
			}
			else {
				$intError = 1;
			}
			break;
	}
} else {
	$intError = 1;
}
if($intError == 0) {
	Vfriend_Function::setMsg($arrMessage[$intAction]);
} else {
	Vfriend_Function::setError($arrError[$intError]);	
}
Vfriend_Function::redirect($strBackUrl);
?>